Skip to content

Conversation

@Wang-Benjamin
Copy link

Problem

When the execution order is changed, the test function testTraceLoggingForBulkUpdates() in MultiDocumentStoreTest.java shows a non-deterministic behavior, where the test sometimes fails with AssertionError.

[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.57 s <<< FAILURE! - in org.apache.jackrabbit.oak.plugins.document.MultiDocumentStoreTest
[ERROR] testTraceLoggingForBulkUpdates[RDBFixture: RDB-H2(file)](org.apache.jackrabbit.oak.plugins.document.MultiDocumentStoreTest)  Time elapsed: 0.279 s  <<< FAILURE!
java.lang.AssertionError

[ERROR] Failures: 
[ERROR]   MultiDocumentStoreTest.testTraceLoggingForBulkUpdates:417
[INFO] 
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0

The root cause of this issue is that failedUpdates is returned as a set by SetUtils.difference. When it is converted to a string for logging in the TRACE log, the order of elements is non-deterministic. But the test expects a specific order "failure for [" + modifiedRow + ", " + deletedRow + "]", resulting in a mismatch.

Command to reproduce the output:

mvn -pl oak-store-document -Dcheckstyle.skip=true -Drat.skip=true \
    edu.illinois:nondex-maven-plugin:2.1.7:nondex \
    -Dtest=org.apache.jackrabbit.oak.plugins.document.MultiDocumentStoreTest#testTraceLoggingForBulkUpdates* \
    -DnondexRuns=10 |& tee nondex-$(date +%s).log

Proposed Fix

Instead of checking for an exact string match with a specific order, the test should check for the presence of the target strings in the log message, regardless of string order. The proposed fix splits the original assertion into small parts to check for the presence of different elements separately. With this fix, the non-deterministic behavior would be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant